package cn.hongwei.controller;

import cn.hongwei.result.R;
import cn.hongwei.service.MediaService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

@RestController
@CrossOrigin
@RequestMapping("/admin/vod/media")
public class AdminMediaController {
    @Autowired
    private MediaService mediaService;
    //1、上传视频
    @PostMapping("upload")
    public R upload(MultipartFile file){
        String videoId = mediaService.upload(file);
        //上传视频 返回视频id
        return R.ok().data("id" , videoId);
    }
    //2、获取播放地址
    @GetMapping("getPlayUrl/{vId}")
    public R getPlayUrl(@PathVariable String vId){
        String playUrl = mediaService.getPlayUrl(vId);
        return R.ok().data("playUrl" , playUrl);
    }
    //3、获取播放凭证
    @GetMapping("getPlayAuth/{vId}")
    public R getPlayAuth(@PathVariable String vId){
        String playAuth = mediaService.getPlayAuth(vId);
        return R.ok().data("playAuth" , playAuth);
    }
}
